package com.jinmdz.fmis.dao.admin.dao;

import com.jinmdz.fmis.dao.admin.dao.provider.ServiceBusinessProvider;
import com.jinmdz.fmis.dao.admin.model.servicebusiness.ServiceBusinessDataListItem;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultType;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;

import java.util.ArrayList;

/**
 * 业务模块使用物品服务关联关系设置
 *
 * @author GuanKui
 * @date 2020/3/16 13:48
 */
public interface ServiceBusinessDao {

    /**
     * 根据业务编码加载业务模块下的数据项列表
     *
     * @param businessType 业务类型
     * @return
     * @author GuanKui
     * @date 2020/3/12  17:23
     */
    @SelectProvider(type = ServiceBusinessProvider.class, method = "listServiceBusinessDataListByBusinessType")
    ArrayList<ServiceBusinessDataListItem> listServiceBusinessDataListByBusinessType(@Param("businessType") String businessType);

    /**
     * 根据service_item_id查询特定业务模块下关联信息
     *
     * @param businessType  指定业务类型
     * @param serviceItemId 服务项目表ID
     * @return
     * @author GuanKui
     * @date 2020/3/12  17:23
     */
    @Select("select id from service_business_item where business_type = #{businessType} and service_item_id = #{serviceItemId} and deleted = 0 limit 1 ")
    @ResultType(Integer.class)
    Integer getServiceBusinessIdByServiceItemId(@Param("businessType") String businessType, @Param("serviceItemId") Integer serviceItemId);

    /**
     * 根据Id加载业务模块下的数据
     *
     * @param id 表ID
     * @return
     * @author GuanKui
     * @date 2020/3/12  17:23
     */
    @Select("select version from service_business_item where id = #{id} and deleted = 0 limit 1 ")
    @ResultType(Long.class)
    Long getServiceBusinessVersionById(@Param("id") Integer id);
}
